﻿function deleteAll(type) {
        //if (action == 'del')
        //    if (!confirm("Do you want to delete the record?"))
        //        return false;
    var del = $(".hdfDel").val();
    var ajax = new ajaxObject("/intranet/CompleteCallback?callbackID=0&status=0&actionName=delAll&del=" + del);
        var response = ajax.response();
        //alert(response);
        if (response == "SUCCESS") {
            //no probs
            window.location = window.location;
        }
        else {
            alert("Error completing callback");
        }
    }

function completeCallback(callbackID, i, type, action) {
    var status = "";
    if (action == null || action == "") {
        var callbackStatusEle = document.getElementById("ResultingAction" + i);
        if (callbackStatusEle == null) {
            alert("Error completing callback");
            return;
        }
        if (callbackStatusEle.selectedIndex == 0) {
            alert("Please select the callback action taken");
            return;
        }
        var status = callbackStatusEle.options[callbackStatusEle.selectedIndex].value;
        if (status == "") {
            alert("Error determining callback action taken");
            return;
        }
    }
    else if (action == 'del')
        if (!confirm("Do you want to delete this record?"))
            return false;
    var ajax = new ajaxObject("/intranet/CompleteCallback?callbackID=" + callbackID + "&status=" + status + "&actionName=" + action);
    var response = ajax.response();
    //alert(response);
    if (response == "SUCCESS") {
        //no probs
        window.location = "/intranet/CustomerCallbacksCare?type=" + type;
    }
    else {
        alert("Error completing callback");
    }
}

$(document).ready(function () {
    $(".chkDel").click(function () {
        var del = $(".hdfDel").val();
        var value = $(this).val();
        if ($(this).is(":checked")) {
            del += "|" + value + "|";
        } else {
            del = del.replace("|" + value + "|", "");
        }
        $(".hdfDel").val(del);
    });
});